<?php
	/**
	 * 生成唯一验证码
	 */
	class RandomCode
	{
		const char_pool = "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLOMNOPQRSTUVWXYZ";

		public function get_random_code($length)
		{
			$code = "";
			$char_arr = str_split(self::char_pool);
			for ($i = 0; $i < $length; $i++) {
				$code .= $char_arr[mt_rand(0, count($char_arr)-1)];
			}
			return $code;
		}
	}

?>